package com.crazy.appium.page;

import org.openqa.selenium.By;

import com.crazy.appium.driver.CrazyMobileDriver;

import io.appium.java_client.MobileElement;

/**
 * @author 沙陌  qq2879897713
 *
 */
public class ProductDetailsPage extends BasePage {
	
	
	public MobileElement getBuy(){
		if(isForceSwitch()){
			return getElement("buy_force");
		}
		return getElement("buy");
	}
	public MobileElement getTuijian(){
		this.driver.switchToContext("NATIVE");
		return getElement("tuijian");
	}
//	boolean isForce=false;

	/**
	 * @param driver
	 * @param platform
	 */
	public ProductDetailsPage(CrazyMobileDriver driver, String platform) {
		super(driver, platform);
		// TODO Auto-generated constructor stub
	}
	
	public boolean isForceSwitch(){
		return this.driver.isElementExist(By.xpath("//html"));
	}
	
	public void clickBuy(){
		getBuy().click();
	}

}
